<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script>
    var visitId = '${visitId}', pageSize = '${pageSize}';

    $(function() {
        $('#pageSelect').val(pageSize).trigger("change");
        change(pageSize)
        $('#pageSelect').change(function() {
            change(this.value);
        })
        $('#pageUp').click(function() {
            var page = +$('#pageSelect').val()
            if(page > 1) {
                $('#pageSelect').val(page - 1).trigger("change");
            }
        })
        $('#pageDown').click(function() {
            var page = +$('#pageSelect').val()
            if(page < pageSize) {
                $('#pageSelect').val(page + 1).trigger("change");
            }
        })
        $('#printOne').click(function() {
            print($('#pageSelect').val())
        })
        $('#printAll').click(function() {
            print('')
        })
    })

    function change(p) {
        $('#img').attr('src', '/static/his/print/' + visitId + '/img/page' + p + '.jpg?datetime='+Math.random())
    }

    /**
     * 生成三测单
     */
    function print(page) {
        $.ajax({
            type: "POST",
            url: ctx + '/nurse/nurseTempInfo/print?pageSize=' + pageSize + '&page=' + page + '&visitId=' +visitId,
            dataType: "json",
            success: function (data) {
                if (data.code == '1' || data.code == 1) {
                    printWindow(data.data);
                } else {
                    toastr.error('生成失败，请联系管理员');
                }
            },
            error: function (data) {
                toastr.error('生成失败，请联系管理员');
            }
        });

    }
</script>

<div class="content-wrap">
    <div class="wrapper" style="bottom: 50px;">
        <ul class="nav nav-tabs">
            <li><a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/nurse/index')">床位列表</a></li>
            <li><a href="#" onclick="loadDiv('mainCenterDiv','${ctx}/nurse/nurseTempInfo/index?visitId=${visitId}&type=${type}')">护理</a></li>
            <li class="active">
                <a href="#">变化曲线图</a>
            </li>
        </ul>
        <section class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive no-border">
                    <div class="datatable-top">
                        <div class="pull-left">
                            <label>页码：</label>
                            <select style="width: 100px" id="pageSelect">
                                <c:forEach begin="1" end="${pageSize}" var="page">
                                    <option value="${page}">第 ${page} 页</option>
                                </c:forEach>
                            </select>
                            <button id="pageUp" class="btn btn-primary">上一页</button>
                            <button id="pageDown" class="btn btn-primary">下一页</button>
                            <button id="printOne" class="btn btn-primary">打印本页</button>
                            <button id="printAll" class="btn btn-primary">打印全部</button>
                        </div>
                    </div>
                    <div class="col-lg-12">
                        <div class="col-lg-12 panel" style="text-align: center">
                            <img src="" id="img"/>

                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
</div>





